package huawei.hwanimation;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.animation.Interpolator;
import o.fqe.c;

public class CubicBezierInterpolator implements Interpolator {
    float ˊ;
    float ˋ;
    float ˎ;
    float ॱ;

    public CubicBezierInterpolator(float f, float f2, float f3, float f4) {
        this.ˊ = 0.0f;
        this.ˋ = 0.0f;
        this.ˎ = 0.0f;
        this.ॱ = 0.0f;
        this.ˊ = f;
        this.ˋ = f2;
        this.ˎ = f3;
        this.ॱ = f4;
    }

    public CubicBezierInterpolator(Context context, AttributeSet attributeSet) {
        this(context.getResources(), context.getTheme(), attributeSet);
    }

    public CubicBezierInterpolator(Resources resources, Theme theme, AttributeSet attributeSet) {
        TypedArray obtainStyledAttributes;
        this.ˊ = 0.0f;
        this.ˋ = 0.0f;
        this.ˎ = 0.0f;
        this.ॱ = 0.0f;
        if (theme != null) {
            obtainStyledAttributes = theme.obtainStyledAttributes(attributeSet, c.ʻ, 0, 0);
        } else {
            obtainStyledAttributes = resources.obtainAttributes(attributeSet, c.ʻ);
        }
        this.ˊ = ˊ(obtainStyledAttributes.peekValue(c.ॱॱ));
        this.ˋ = ˊ(obtainStyledAttributes.peekValue(c.ͺ));
        this.ˎ = ˊ(obtainStyledAttributes.peekValue(c.ʽ));
        this.ॱ = ˊ(obtainStyledAttributes.peekValue(c.ˏॱ));
        obtainStyledAttributes.recycle();
    }

    private float ˊ(TypedValue typedValue) {
        if (typedValue == null) {
            return 1.0f;
        }
        if (typedValue.type == 6) {
            return TypedValue.complexToFloat(typedValue.data);
        }
        if (typedValue.type == 4) {
            return typedValue.getFloat();
        }
        if (typedValue.type >= 16 && typedValue.type <= 31) {
            return (float) typedValue.data;
        }
        Log.i("CubicBezierInterpolator", "type = " + typedValue.type);
        return 1.0f;
    }

    public float getInterpolation(float f) {
        return ˋ(2.5E-4f * ((float) ˎ(f)));
    }

    private float ˏ(float f) {
        return ((((((1.0f - f) * 3.0f) * (1.0f - f)) * f) * this.ˊ) + (((((1.0f - f) * 3.0f) * f) * f) * this.ˎ)) + ((f * f) * f);
    }

    protected float ˋ(float f) {
        return ((((((1.0f - f) * 3.0f) * (1.0f - f)) * f) * this.ˋ) + (((((1.0f - f) * 3.0f) * f) * f) * this.ॱ)) + ((f * f) * f);
    }

    long ˎ(float f) {
        long j = 0;
        long j2 = 4000;
        while (j <= j2) {
            long j3 = (j + j2) >>> 1;
            float ˏ = ˏ(2.5E-4f * ((float) j3));
            if (ˏ < f) {
                j = j3 + 1;
            } else if (ˏ <= f) {
                return j3;
            } else {
                j2 = j3 - 1;
            }
        }
        return j;
    }

    public String toString() {
        StringBuffer stringBuffer = new StringBuffer("CubicBezierInterpolator");
        stringBuffer.append("  mControlPoint1x = ").append(this.ˊ);
        stringBuffer.append(", mControlPoint1y = ").append(this.ˋ);
        stringBuffer.append(", mControlPoint2x = ").append(this.ˎ);
        stringBuffer.append(", mControlPoint2y = ").append(this.ॱ);
        return stringBuffer.toString();
    }
}
